﻿using Entity.Blog;
using Entity.Blog.Dto;
using Entity.Blog.Dto.BlogComment;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service.Blog;
using Service.Finance;

namespace AnQinManagermentBackendAPI.Controller
{
    /// <summary>
    /// 博客正文评论
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    [AllowAnonymous]
    public class BlogCommentsController : ControllerBase
    {
        /**
         * 业务接口
         */
        private readonly BlogCommentService _service;

        /**
         * 构造函数注入
         */
        public BlogCommentsController(BlogCommentService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        [ProducesResponseType(typeof(BlogComment), 200)]
        public async Task<IActionResult> GetList([FromQuery] BlogCommentSearchDto model)
        {
            var response = await _service.GetList(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> Add([FromBody] BlogCommentAddDto model)
        {
            var response = await _service.Add(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> Delete([FromQuery] string Id)
        {
            var response = await _service.Delete(Id);
            return StatusCode(response.Status, response);
        }

    }
}
